#import "..\\COM\\Obj\\COM.tlb" no_namespace, rename("GUID","MYGUID"), named_guids
#import "..\\CONTAIN\\Obj\\CONTAIN.tlb" no_namespace, rename("GUID","MYGUID"), named_guids,\
                                        rename("IAggregate","MyIAggregate")
#include <Windows.h>

int main()
{
    HRESULT hResult;
    IAggregate* lpIAggregate = nullptr;
    IAggregate* lpIAggregate2 = nullptr;
    IContain* lpIContain = nullptr;

    CoInitialize(0);

    do
    {
        hResult = CoCreateInstance(CLSID_CONTAIN, nullptr, CLSCTX_INPROC_SERVER, 
            IID_IAggregate, (void**)&lpIAggregate);
        if (hResult != S_OK) break;

        hResult = lpIAggregate->QueryInterface(IID_IContain, (void**)&lpIContain);
        if (hResult != S_OK) break;

        hResult = CoCreateInstance(CLSID_AGGREGATE, nullptr, CLSCTX_INPROC_SERVER, 
            IID_IAggregate, (void**)&lpIAggregate2);
        if (hResult != S_OK) break;

        lpIAggregate->AggregateTest();
        lpIContain->ContainTest();
        lpIAggregate2->AggregateTest();

    } while (FALSE);

    if (lpIAggregate2)
        lpIAggregate2->Release();

    if (lpIAggregate)
        lpIAggregate->Release();

    if (lpIContain)
        lpIContain->Release();

    CoFreeUnusedLibraries();

    CoUninitialize();

    return 0;
}